module Present
  def present(*args, &block)
    options = args.pop if args.last.is_a? Hash
    macro = args.empty? ? nil : args.first

    # get the macro object
    if macro
      raise NotImplementedError
    elsif object = options.delete(:list)
      macro = Present::List.new(options, &block)
    elsif object = options.delete(:form)
      macro = Present::Form.new(options, &block)
    end

    macro.view = self
    macro.render(object)
  end

  # Links the assets (stylesheets/javascripts) needed to properly render
  # and use Presenting. You can pick what layout and what colors to use.
  def presenting_assets(layout = :default_layout, colors = :default_colors)
    o = ''
    o << stylesheet_link_tag("presenting/#{layout}")
    o << stylesheet_link_tag("presenting/#{colors}")
    o
  end
end
